home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / cmouse.zip / GMICE.C < prev    next >
Text File  |  1988-04-26  |  3KB  |  100 lines

  1. /* GMICE.C: Illustrates the default graphics mouse cursor, plus    */
  2. /*    the four from GMOUSCUR.I                                     */
  3.  
  4. /* INCLUDES AND DEFINES */
  5. #include <stdio.h>
  6. #include <dos.h>
  7. #include <graphics.h>
  8. #include <c:\articles\porter\mouse2\mouse.inc>
  9. #include <c:\articles\porter\mouse2\gmouscur.i>
  10. #ifndef  TRUE
  11. #define  TRUE  -1
  12. #define  FALSE  0
  13. #endif
  14. #define  EVENTMASK  0x54   /* event when any mouse button released */
  15.  
  16. /* LOCAL PROTOTYPES */
  17. void demo (GCURSREC, char*);
  18. void graphicScreen (char*);
  19. void identify (char*);
  20.  
  21. /* GLOBALS */
  22. union REGS  reg;
  23. int   driver = CGA, mode = CGAHI;
  24. char  path [] = "C:\TC";
  25.  
  26. void main ()
  27. {
  28. resetRec    *theMouse;
  29.  
  30. /* Set up for run */
  31.   initGCurs();                     /* initialize the cursor images */
  32.   theMouse = mReset();                          /* reset the mouse */
  33.   if (theMouse->exists) {
  34.     mInstTask (EVENTMASK, FP_SEG (handler),      /* install handler*/
  35.                FP_OFF (handler));
  36.     theEvents = MK_FP (_psp, 0x00C0);     /* point to event record */
  37.  
  38. /* Show default cursor */
  39.     graphicScreen ("Default cursor");
  40.     mShow();                                     /* turn on cursor */
  41.     theEvents->flag = 0;
  42.     while (theEvents->flag == 0)                 /* wait for click */
  43.       ;
  44.  
  45. /* Show the custom cursors */
  46.     demo (check, "Check");
  47.     demo (arrow, "Left arrow");
  48.     demo (cross, "Cross");
  49.     demo (hand,  "Pointing hand");
  50.     demo (iBeam, "I-Beam");
  51.     theMouse = mReset();                            /* reset mouse */
  52.     closegraph();
  53.   }
  54. } /* ------------------------ */
  55.  
  56. void demo (GCURSREC cursor, char title[])  /* show graphics cursor */
  57. {
  58.   identify (title);
  59.   mGraphCursor (cursor.hotX, cursor.hotY, (unsigned) (_DS),
  60.                 (unsigned) (cursor.image));
  61.   theEvents->flag = 0;
  62.   while (theEvents->flag == 0)                   /* wait for click */
  63.       ;
  64. } /* ------------------------ */
  65.  
  66. void graphicScreen (char  title[])       /* set up graphics screen */
  67. {
  68. int  x, y;
  69. char prompt [30];
  70.  
  71.   initgraph (&driver, &mode, path);
  72.   if (graphresult() == grOk) {
  73.     identify (title);
  74.         strcpy (prompt, "Click any button to continue");
  75.     x = (getmaxx() - textwidth (prompt)) / 2;
  76.         outtextxy (x, getmaxx() - 20, prompt);
  77.  
  78.   /* draw rectangle as backdrop for cursor */
  79.         setfillstyle (SOLID_FILL, 1);
  80.         setcolor (1);
  81.     x = (getmaxx()/2) - 50;
  82.         y = (getmaxy()/2) - 50;
  83.         rectangle (x, y, x+100, y+100);
  84.         floodfill (getmaxx()/2, getmaxy()/2, 1);
  85.     }
  86. } /* ------------------------ */
  87.  
  88. void identify (char *title)
  89. {
  90. int    x;
  91.  
  92.   setviewport (0, 0, getmaxx(), 30, TRUE);
  93.     clearviewport();
  94.     settextstyle (DEFAULT_FONT, HORIZ_DIR, 1);
  95.   x = (getmaxx() - textwidth (title)) / 2;
  96.     outtextxy (x, 20, title);
  97.     setviewport (0, 0, getmaxx(), getmaxy(), TRUE);
  98. } /* ------------------------ */
  99.  
  100.